import os
from tool.handle.Change_Filename.file_method import Location_Sample
# from class_define import case_rename
from tool.handle.Change_Filename.class_define import case_rename
# import tqdm
import re
# if __name__=='__main__':
def filename_change(file_path,app_path,mode_run,user_database,app_name):
    # file_path=str(input("file_path:"))
    # app_path=str(input("App_path:"))
    # app_path=str(input("app_path[1:JULONG or ?]:"))
    # mode_run=str(input("the mode[1:no_error or no?]:"))
    # app_path_JULONG="Src_Code\\APP_work\\ccm_auto_test\\app_x86"
    tmp = case_rename.case_name()
    # if app_path=="1":
    #     app_path=app_path_JULONG
    #     tmp.model_machine_num="0"
    tmp.model_type=app_name
    tmp.mode_run=mode_run
    tmp.absolute_file_path=Location_Sample.win_to_ubuntu_filepath(file_path,"Sample")
    tmp.absolute_app_path = Location_Sample.win_to_ubuntu_filepath(app_path, "Sample")
    #find all sample which need change
    #需要匹配的模式
    tmp.change_pattern = re.compile(r'(.*?_.*?_.*?)_(Err0)_(LastErr0x0)_(Den0)_(Dir[0-4])_(Ver0)_(SN0)')
    tmp.find_sample_file()
    #sure?
    # choice_y_n=input("yes or no?[Y or N]:")
    # if choice_y_n=="Y":
        #run
    user_database.init_progress_bar_value()
    value= tmp.run_change_filename(user_database)
    return value
    # print("the program finish!")